import { Map } from "immutable"

import {
    CHANGE_LEFT_LIST,
    CHANGE_CURRENT_INDEX,
    CHANGE_PLAY_LIST_DETAIL,
} from "./constants"

let defaultState = Map({
    leftRankingList: [],
    currentIndex: 0,//当前选择的排行榜列表索引
    playListDetail: {},//当前选中的左边那个排行榜的的详情
});


function reducer (state = defaultState, action) {
    switch (action.type) {
        case CHANGE_LEFT_LIST:
            return state.set("leftRankingList", action.list)

        case CHANGE_CURRENT_INDEX:
            return state.set("currentIndex", action.index)

        case CHANGE_PLAY_LIST_DETAIL:
            return state.set("playListDetail", action.playlist)

        default:
            return state;
    }
}

export default reducer;